
target("bb_test")
    set_kind("binary")
    add_files("bb_test.c")
    add_deps("ar8030_client")

    add_includedirs("./" , {public=true})
    on_load(function (target)
        local ardir = path.join(os.scriptdir(),"../../../../")

        if os.isfile(path.join(os.scriptdir(), "bb_api.h")) == false then
            os.trycp(path.join(ardir , "release/inc/bb_api.h") , os.scriptdir())
        end

        if os.isfile(path.join(os.scriptdir(), "prj_rpc.h")) == false then
            os.trycp(path.join(ardir , "release/inc/prj_rpc.h") , os.scriptdir())
        end

        if os.isfile(path.join(os.scriptdir(), "bb_config.h")) == false then
            for _,conpath in ipairs(
                    {
                        "release/inc/bb_config.h"
                    }
                )do
                if os.isfile(path.join(ardir,conpath)) then
                    os.cp(path.join(ardir,conpath) , os.scriptdir())
                    break
                end
            end
        end
    end)

if is_plat("android") == nil then
    add_links("pthread")
end

on_install(function (target)
    dhpath = path.join(target:installdir() , "bin")
    os.mkdir(dhpath)

    os.cp(target:targetfile() , dhpath)
end)
